<?php

/**
 * Dicfro
 *
 * PHP 5
 *
 * @category   DicFro
 * @package    View
 * @subpackage Scripts_Interface
 * @author     Michel Corne <mcorne@yahoo.com>
 * @copyright  2008-2013 Michel Corne
 * @license    http://opensource.org/licenses/gpl-3.0.html GNU GPL v3
 */

?>

<div>

<!-- logo -->
<span class="nowrap">

  <a class="logo" href="<?=$this->linksHelper->setHomeLink();?>">
    <span style="color:blue;font-size:120%;">d</span><span style="color:green;vertical-align:-20%;">i</span><span style="color:orange;">c</span><span style="color:red;font-size:120%;">f</span><span style="color:blue;">r</span><span style="color:green;vertical-align:20%;">o</span>
  </a>

</span>

<!-- search block -->
<span class="nowrap">
  <input type="hidden" id="action" value="<?=$this->linksHelper->setWordLink();?>"/>
  <input type="hidden" id="dictionary-language" value="<?=$this->dictionary['language'];?>"/>

  <input class="word" type="text" id="word"
         placeholder="<?=$this->translate('Enter a word');?>"
         title="<?=$this->translate('Enter a word then press the ENTER key or click on the button');?>"
         value="<?=$this->escape($this->word);?>"
         onkeypress="isEnterKey(event) && searchWord('<?=$this->linksHelper->setWordLink();?>');" />

  <input class="button search" type="button"
         onclick="searchWord('<?=$this->linksHelper->setWordLink();?>')"
         value="<?=$this->translate('Search');?>" />

</span>

<!-- dictionary select block -->

<span class="nowrap" >

  <select class="dict" id="dictionary"
          onchange="openDictionary('<?=$this->linksHelper->setDictionaryLink();?>')">

    <?php foreach($this->dictionariesHelper->getGroups($this->dictionary['url']) as $optgroup) :?>
      <optgroup label="<?=$optgroup['label'];?>">

        <?php foreach($optgroup['options'] as $option) :?>

          <option value="<?=$option['value'];?>"
                  title="<?=$option['title'];?>"
                  <?php if($option['selected']):?>selected="selected"<?php endif;?> >
            <?=$option['text'];?>
          </option>

        <?php endforeach;?>

      </optgroup>
    <?php endforeach;?>

  </select>

</span>

<!-- arrows-->

<?php if(isset($this->page)):?>

<span class="nowrap">

  <img class="button" src="<?=$this->setLinkUrl('img/go-previous.png');?>"
       title="<?=$this->translate('Previous page');?>"
       onclick="location.assign('<?=$this->linksHelper->setPreviousPageLink();?>');" />
  <img class="button" src="<?=$this->setLinkUrl('img/go-next.png');?>"
       title="<?=$this->translate('Next page');?>"
       onclick="location.assign('<?=$this->linksHelper->setNextPageLink();?>');" />

</span>

<!-- page and volume block -->
<span class="page-volume">

  <?php if (isset($this->entries)):?>
    <select class="entries" id="entries"
            onchange="goEntry('<?=$this->linksHelper->setGoPageLink(true);?>')">

      <?php foreach($this->entriesHelper->getEntries() as $option) :?>
        <option value="<?=$option['value'];?>"
                <?php if(! empty($option['selected'])):?>selected="selected"<?php endif;?> >
           <?=$option['text'];?>
        </option>
      <?php endforeach;?>

    </select>

  <?php else:?>
    <input class="first-word" type="text" disabled="disabled"
           title="<?=$this->translate('First word of the page, please contact us in case of error');?>"
           value="<?=$this->firstWord;?>" />
  <?php endif;?>

  <span class="page"><?=$this->translate('Page');?></span>
  <input class="page" type="text" id="page"
         title="<?=$this->translate('Enter a number then press the ENTER key or click on the button');?>"
         value="<?=$this->escape($this->page);?>"
         onkeypress="isEnterKey(event) && goPage('<?=$this->linksHelper->setGoPageLink();?>');" />

  <?php if(! empty($this->dictionary['volume'])):?>
    <span class="volume"><?=$this->translate('Volume');?></span>
    <input class="volume" type="text" id="volume"
           <?php if ($this->dictionary['volume'] == 'readonly'):?>
             disabled=disabled
           <?php else:?>
             title="<?=$this->translate('Enter a number then press the ENTER key or click on the button');?>"
           <?php endif;?>
           value="<?=$this->escape($this->volume);?>"
           onkeypress="isEnterKey(event) && goPage('<?=$this->linksHelper->setGoPageLink();?>');" />
  <?php endif;?>

  <input class="button" type="button" onclick="goPage('<?=$this->linksHelper->setGoPageLink();?>')"
         value="<?=$this->translate('Display');?>" />

</span>

<?php endif;?>

</div>

